fix: re enable scopes (CM-1231) - #4210
Conversation
There was a problem hiding this comment.
Pull request overview
This PR re-enables Auth0 scope enforcement for the public v1 packages endpoints, now that the required scopes exist in the Auth0 staging tenant. It ensures packages-related endpoints consistently require both read:packages and read:stewardships, aligning access control with the data returned by these endpoints (which includes stewardship fields).
Changes:
- Restores
requireScopes([SCOPES.READ_PACKAGES, SCOPES.READ_STEWARDSHIPS], 'all')onPOST /v1/packages:batch-stewardship. - Re-enables scope enforcement for all
/v1/packages/*endpoints by applying a singlerouter.use(requireScopes(...))inpackagesRouter. - Removes the previously-commented-out per-route scope middleware blocks and TODOs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| backend/src/api/public/v1/packages/index.ts | Adds a top-level router.use(requireScopes([...], 'all')) so all /packages endpoints require both scopes. |
| backend/src/api/public/v1/index.ts | Restores requireScopes([...], 'all') on POST /packages:batch-stewardship and re-adds SCOPES import. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0a97231 to
b3c8d33
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b3c8d33. Configure here.
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
5258b1d to
06e1d4a
Compare
| packagesRateLimiter, | ||
| // TODO: restore once read:stewardships is added to Auth0 staging tenant | ||
| // requireScopes([SCOPES.READ_STEWARDSHIPS]), | ||
| requireScopes([SCOPES.READ_PACKAGES, SCOPES.READ_STEWARDSHIPS], 'all'), |
| router.get('/metrics', safeWrap(metricsHandler)) | ||
| router.get( | ||
| '/metrics', | ||
| requireScopes([SCOPES.READ_PACKAGES, SCOPES.READ_STEWARDSHIPS], 'all'), |
| router.get('/metrics', safeWrap(metricsHandler)) | ||
| router.get( | ||
| '/metrics', | ||
| requireScopes([SCOPES.READ_PACKAGES, SCOPES.READ_STEWARDSHIPS], 'all'), |
| // requireScopes([SCOPES.WRITE_STEWARDSHIPS]), | ||
| safeWrap(openStewardship), | ||
| ) | ||
| router.post('/', requireScopes([SCOPES.WRITE_STEWARDSHIPS]), safeWrap(openStewardship)) |

Summary
Re-enables Auth0 scope enforcement on all public packages endpoints after the scopes were added to the Auth0 staging tenant.
Changes
requireScopesmiddleware onPOST /packages:batch-stewardship— requires bothread:packagesandread:stewardshipsGET /packages,GET /packages/metrics,GET /packages/detail— requires bothread:packagesandread:stewardshipsrouter.use()at the top ofpackagesRouterfor clarityType of change
JIRA ticket
ticket
Note
High Risk
Tightens authorization across many public endpoints and switches several checks from
'any'to'all', so tokens missing either read scope or write stewardship scope will start failing where they previously succeeded.Overview
Re-enables
requireScopeson public v1 routes that were temporarily left open pending Auth0 staging scope configuration. Read paths now require bothread:packagesandread:stewardships('all'mode); stewardship mutations requirewrite:stewardships.Coverage spans
/akrites, legacy/ossprey,/packages(including a top-levelrouter.usefor all package GETs),/stewardships, andPOST /packages:batch-stewardship. AddsWRITE_STEWARDSHIPStoSCOPESand removes the related TODO comments.Reviewed by Cursor Bugbot for commit 06e1d4a. Bugbot is set up for automated code reviews on this repo. Configure here.